
package com.yhcrt.listener;

import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.log4j.Logger;

import com.yhcrt.utils.PropertiesUtil;

/**
 * 启动加载 初始化系统数据
 * @author fk
 * 2021年10月14日
 * 
 */
public class ServletContextLoaderListener implements ServletContextListener {
	private static final Logger log = Logger.getLogger(ServletContextLoaderListener.class);
	
	public void contextInitialized(ServletContextEvent servletContextEvent) {
		log.info("start 系统初始化...");
		
		ServletContext servletContext = servletContextEvent.getServletContext();
		/**读取配置文件**/
		Map<String, String> map = PropertiesUtil.getProperties("properties/config.properties");
		for (Map.Entry<String, String> entry : map.entrySet()) {
			servletContext.setAttribute(entry.getKey(),entry.getValue());
		}
        log.info("end 系统初始化...");
	}

    public void contextDestroyed(ServletContextEvent servletContextEvent) {  
    	//释放资源
    }   

}